package lgs.hm.aop2;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class AspectArgs {
	
	@Around("args(aa)")
	public Object around(ProceedingJoinPoint pjp,String aa) {
		System.out.println("================"+aa);
		Object[] args = pjp.getArgs();
		try {
			return pjp.proceed(args);
		} catch (Throwable e) {
			e.printStackTrace();
		}
		return null;
	}
	
	@Around("@args(lgs.hm.aop2.Changge)") 
	//拦截目标方法上有一个参数，这个参数是一个自定义类型，这个类型上有一个自定义注解aa
	
	public Object around1(ProceedingJoinPoint pjp) {
		System.out.println("-----------------------------");
		Object[] args = pjp.getArgs();
		try {
			return pjp.proceed(args);
		} catch (Throwable e) {
			e.printStackTrace();
		}
		return null;
	}
	
	@Around("target(lgs.hm.aop2.MyDate)")
	public Object around11(ProceedingJoinPoint pjp) {
		System.out.println("******************************");
		Object[] args = pjp.getArgs();
		try {
			return pjp.proceed(args);
		} catch (Throwable e) {
			e.printStackTrace();
		}
		return null;
	}


}
